<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/common/include/page.jsp"%>
<jsp:useBean id="pojo" class="com.jjh.users.pojo.AAdmins"/>
<!DOCTYPE HTML>
<html>
	<head>
		<%@ include file="/common/include/title.jsp"%>
		<title>添加管理员 - 用户管理 - 用户中心</title>
		<meta name="keywords" content="H-ui.admin v3.1,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
		<meta name="description" content="H-ui.admin v3.1，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
	</head>
	<body>
		<nav class="breadcrumb">
			<i class="Hui-iconfont">&#xe67f;</i> 首页
			<span class="c-gray en">&gt;</span> 用户管理
			<span class="c-gray en">&gt;</span> 管理员添加
			<a class="btn btn-success radius r" style="line-height: 1.6em; margin-top: 3px"
				href="javascript:location.replace(location.href);" title="刷新">
				<i class="Hui-iconfont">&#xe68f;</i>
			</a>
		</nav>
		<article class="page-container">
			<form class="form form-horizontal" id="form" action="${rootPath}/back/admin/adminsInsertSubmit">
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">角色：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<span class="select-box" style="width:150px;">
							<select class="select" name="roleId" size="1">
								<c:forEach items="${requestScope.roleList }" var="listTemp" varStatus="stat">
									<option value="${listTemp.id }" ${requestScope.one.roleId == listTemp.id ? 'selected' : '' }>${listTemp.name }</option>
								</c:forEach>
							</select>
						</span> 
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>邮箱：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" placeholder="请输入邮箱" name="email" id="email">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>初始密码：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="password" class="input-text" autocomplete="off" value="" placeholder="请输入密码" id="password" name="password">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>确认密码：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="password" class="input-text" autocomplete="off"  placeholder="请输入确认密码" id="password2" name="password2">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>真实姓名：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" value="" placeholder="请输入真实姓名" id="trueName" name="trueName">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>qq：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" value="" placeholder="请输入qq" id="qq" name="qq">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机号：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" value="" placeholder="请输入手机号" id="phone" name="phone">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>性别：</label>
					<div class="formControls col-xs-8 col-sm-9 skin-minimal">
						<c:set value="0" var="currCount"/>
						<c:forEach items="${pojo.enumsMap }" var="me" varStatus="stat">
							<%-- me:map中的entrySet ;me.key:键,me.value:值--%>
							<c:if test="${fn:startsWith(me.key,'SEX_')}">
								<c:set value="${fn:split(me.key, '-') }" var="keys"/>
								<div class="radio-box">
									<label for="${currCount }">
										<input name="sex" type="radio" id="${me.key }" value="${keys[1] }"  
											${currCount == '0' ? 'checked' : '' }>
										${me.value }
									</label>
								</div>
								<c:set value="${currCount + 1 }" var="currCount"/>
							</c:if>
						</c:forEach>
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>状态：</label>
					<div class="formControls col-xs-8 col-sm-9 skin-minimal">
						<c:set value="0" var="currCount"/>
						<c:forEach items="${pojo.enumsMap }" var="me" varStatus="stat">
							<%-- me:map中的entrySet ;me.key:键,me.value:值--%>
							<c:if test="${fn:startsWith(me.key,'STATUS_')}">
								<c:set value="${fn:split(me.key, '-') }" var="keys"/>
								<div class="radio-box">
									<label for="${currCount }">
										<input name="status" type="radio" id="${me.key }" value="${keys[1] }"  
											${currCount == '0' ? 'checked' : '' }>
										${me.value }
									</label>
								</div>
								<c:set value="${currCount + 1 }" var="currCount"/>
							</c:if>
						</c:forEach>
					</div>
				</div>
				<div class="row cl">
					<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
						<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
					</div>
				</div>
			</form>
		</article>
		
		<%@ include file="/common/include/footer.jsp"%>
		
		<!--请在下方写此页面业务相关的脚本-->
		<script type="text/javascript" src="${rootPath }/common/resource/H-ui.admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
		<script type="text/javascript" src="${rootPath }/common/resource/H-ui.admin/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
		<script type="text/javascript" src="${rootPath }/common/resource/H-ui.admin/lib/jquery.validation/1.14.0/messages_zh.js"></script> 
		<script type="text/javascript">
		$(function(){
			$('.skin-minimal input').iCheck({
				checkboxClass: 'icheckbox-blue',
				radioClass: 'iradio-blue',
				increaseArea: '20%'
			});
			
			/*
				表单验证的框架;
				$();id选择器
			*/
			$("#form").validate({
				/* rules:规则 */
				rules:{
					/* 表单中input的name的值,不是id的值 */
					trueName:{
						/* 必须填写 */
						required:true,
						/* 最小长度 */
						minlength:2,
						/* 最大长度 */
						maxlength:16
					},
					/* 密码 */
					password:{
						required:true,
					},
					/* 确认密码 */
					password2:{
						required:true,
						/* 必须和谁一样 */
						equalTo: "#password"
					},
					/* 性别必填 */
					sex:{
						required:true,
					},
					/* 性别必填 */
					phone:{
						required:true,
						/* 是手机号;必须是符合要求的手机号 */
						isPhone:true,
					},
					/* 邮箱 */
					email:{
						/* 必须填写 */
						required:true,
						/* 是邮箱 */
						email:true,
					},
					/* 角色 */
					adminRole:{
						required:true,
					},
				},
				onkeyup:false,
				focusCleanup:true,
				success:"valid",
				submitHandler:function(form){
					$(form).ajaxSubmit({
						type: 'post',
						/* url: "${rootPath}/back/admin/adminsInsertSubmit" , */
						success: function(data){
							/**
								参数1:提示信息
								参数2:弹出信息的可选项;time:超时
								参数3:执行完以后调用此方法
							*/
							layer.msg(data.info,{icon:1,time:3000},function()
							{
								/* 成功 */
								if(data.code == '0')
								{
									/* 刷新父窗口 */
									var index = parent.layer.getFrameIndex(window.name);
									parent.$('.btn-refresh').click();
									/* 关闭当前窗口 */
									parent.layer.close(index);
								}
							});
						},
		                error: function(XmlHttpRequest, textStatus, errorThrown){
							layer.msg('error!',{icon:1,time:1000});
						},
						dataType:'json'
					});
				}
			});
		});
		</script> 
		<!--/请在上方写此页面业务相关的脚本-->
	</body>
</html>